import { createRouter, createWebHistory } from "vue-router";
import HomeLayout from "@/layout/HomeLayout.vue";
import EmployeesView from "@/views/EmployeeManage/EmployeesView.vue";
import EmployeeLoginView from "@/views/loginAndRegister/EmployeeLoginView.vue";
import DepartmentsView from "@/views/DepartmentManage/DepartmentsView.vue";
import store from "@/store";
import AddEmployeeView from "@/views/EmployeeManage/AddEmployeeView.vue";
import AddDepartmentsView from "@/views/DepartmentManage/AddDepartmentsView.vue";
import { salary } from "@/router/salary";
import { patient } from "@/router/patient";
import { medicine } from "@/router/medicine";
import { Room } from "@/router/Room";
import { Regnus } from "@/router/Regnus";
import { doctor } from "@/router/doctor";
import AddEmployeeView2 from "@/views/EmployeeManage/AddEmployeeView2.vue";
import ShowDataView from "@/views/ShowDataView.vue";
// import { Room } from "@/router/Room";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "login",
      component: EmployeeLoginView
    },
    {
      path: "/login",
      component: EmployeeLoginView
    },
    {
      path: "/home",
      name: "home",
      component: HomeLayout,
      children: [
        {
          path: "/home/data",
          name: "数据统计",
          component: ShowDataView
        },
        {
          path: "/home/emps",
          name: "员工信息",
          component: EmployeesView
        },
        {
          path: "/home/addemps",
          name: "添加员工",
          component: AddEmployeeView
        },
        {
          path: "/home/addemps2",
          name: "添加管理员",
          component: AddEmployeeView2
        },
        {
          path: "/home/updatemps",
          name: "修改员工",
          component: AddEmployeeView
        },
        //部门
        {
          path: "/home/deps",
          name: "部门信息",
          component: DepartmentsView
        },
        {
          path: "/home/adddeps",
          name: "添加部门",
          component: AddDepartmentsView
        },
        {
          path: "/home/updatedeps",
          name: "修改部门",
          component: AddDepartmentsView
        },
        //
        // 薪资
        ...salary,
        //患者相关
        ...patient,
        //药品
        ...medicine,
        //房间
        ...Room,
        //挂号
        ...Regnus,
        // 医生处理
        ...doctor

      ]
    }
  ]
});
router.beforeEach((to, from, next) => {
  store.dispatch("user/increment", JSON.parse(sessionStorage.getItem("user")));
  next();
});

export default router;
